import * as actionTypes from './actionTypes';

export function increase(caption) {
	return {
		type: actionTypes.INCREMENT,
		caption: caption
	};
}

export function decrease(caption) {
	return {
		type: actionTypes.DECREMENT,
		caption: caption
	};
}

export function increaseIfOdd(caption) {
	return ((dispatch, getState) => {
		if (getState().counter[caption] % 2 === 0) {
			return;
		}
		dispatch(increase(caption));
	});
}

export function increaseDelay(caption, delay = 1000) {
	return ((dispatch, getState) => {
		setTimeout(() => {
			dispatch(increase(caption));
		}, delay);
	});
}
			